<?php

  namespace Admin\Controller;
  use Think\Controller;

  class PicController extends Controller

  {

  	public function index()

  	{

       // 实例化model类
      $model = M('pic');
      $data = $model->select();
      $this->assign('data',$data);
      $this->display();

  	}

   public function upload()

   {

     // 实例化文件上传类
    $config = array(

        'rootPath' => 'Public/',
        
        'maxSize'    =>    3145728,  
        'savePath'   =>    './Public/Uploads/', 
        'saveName'   =>    array('uniqid',''),   
        'exts'       =>    array('jpg', 'gif', 'png', 'jpeg'), 
       'autoSub'    =>    true,   
       'subName'    =>    array('date','Ymd'),

      );

    $upload = new \Think\Upload($config);

    // 2.执行文件上传操作(单文件上传)
    $info = $upload->uploadOne($_FILES['file']);
   
    // 判断文件上传是否成功
    if($info){
         
         echo $info['savepath'].$info['savename'];

    }else{

         echo $upload->getError();
    }
   
       exit;

   }
    

  }
